package main


import (
"fmt"
"time"
"math/rand"
)

//3 生产者 3 消费者  3个工人 有 100个工作



func work(){

   for {
		   select {
		       case <- ina :

		         go  xiaofei()

		   }
	      fmt.Println("one")
   }
   time.Sleep(time.Second*10)
   fmt.Println("ok")
}

func xiaofei(){
   a := rand.Intn(10)
   fmt.Println("start ",a)
   time.Sleep(time.Second * time.Duration(a))
   ina <- 1

}

var ina = make(chan int ,5)

func main(){
   
   for i:= 0;i<5;i++{
     ina <- 1
   }

   go work()

   time.Sleep(time.Second*10000)

   fmt.Println("ok")
}



